package view;

import java.awt.FlowLayout;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class FootPanel extends JPanel implements Runnable {

	Date datum;
	Date zeit;
	
    SimpleDateFormat datumFormat;
    SimpleDateFormat zeitFormat;
    JLabel zeitPunktLabel;
	
	public FootPanel() {
		this.setLayout(new FlowLayout(FlowLayout.RIGHT));
        zeitPunktLabel = new JLabel();
		add(zeitPunktLabel);
	}

	@Override
	public void run() {
		datum = new Date(); 
		datumFormat = new SimpleDateFormat("dd.MM.yyyy");
	    
	    //Systemzeit
	    Date zeit = new Date();
	    zeitFormat = new SimpleDateFormat("hh:mm");

	    
		// TODO Auto-generated method stub
		while ( true ) {
		    zeit.setTime(System.currentTimeMillis());
		   	zeitPunktLabel.setText( "Datum: " + datumFormat.format(datum) + " Uhrzeit: " + zeitFormat.format(zeit));
		   	try {
				Thread.currentThread().sleep(900);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
